Formulas for Token Calculator
The Token Calculator activity contains the following formulas. Browse the formulas by their categories using the right-hand menu.
Mathematics
Name | Format | Description |
---|---|---|
Absolute | ABS(number) | Returns the absolute value of number. |
Addition | number1 + number2; date + number; number + date | Adds two numbers or a number and a date. |
Average | AVG(number1, number2, ...) | Averages the input list, ignoring nonnumerical items. |
AVERAGEA | AVERAGEA(value1, value2, ...) | Averages the input list, treating boolean TRUE as 1 and other nonnumerical items as 0. |
Average If | AVERAGEIF([value1, value2, ...], condition) | Averages the items that satisfy the condition. |
Ceiling | CEILING(number) | Returns the smallest integer that is greater than or equal to the input number. |
Choose | CHOOSE(index, value1, value2, ...) | Chooses the item at the given index in the list. |
CHOOSEA | CHOOSEA(index, value1, value2, ...) |
Expands array items as part of the list and chooses the item at the given index in the list. Multi-value tokens are treated as arrays. Example: CHOOSEA(5, 1, 3, [5, 6, 7]) returns 7. |
COUNTA | COUNTA(value1, value2, ...) | Counts items in the input list, including items in arrays and multi-value tokens. |
Count If | COUNTIF([value1, value2, ...], condition) | Counts the number of items that satisfy condition. |
Count Number | COUNT(item1, item2, ...) |
Counts numerical items in the input list. Example: COUNT(2, "sit", "stand", 9) returns 2. |
Count Unique | COUNTUNIQUE([value1, value2, ...]) | Counts the distinct items in the input list. |
Division | number1 / number2 | Divides number1 by number2. |
Even | EVEN(number) | Returns the closest even number to the input number. |
Epoch | EPOCH(n) | Returns the datetime that is n seconds after the Unix epoch time. |
Exponent | EXP(p) | Returns ep. |
Floor | FLOOR(number) | Returns the largest integer that is less than or equal to the input number. |
Integer Division | number1 // number2 | Divides the two numbers, dropping the fractional part. |
Large | LARGE([number1, number2, ...], n) | Returns the nth largest item in the list of numbers. |
Logarithm | LOG(number, base) | The power to which base must be raised to produce number. |
Logarithm (base 10) | LOG10(number) | Logarithm with base 10. |
Logarithm (natural) | LN(number) | Logarithm with base e. |
Maximum | MAX(number1, number2, ...) | Returns the maximum number in the list, ignoring nonnumerical items. |
MAXA | MAXA(value1, value2, ...) | Returns the maximum number in the list, treating boolean TRUE as 1 and any other nonnumerical items as 0. |
Median | MEDIAN(number1, number2, ...) | Returns the median value of the input list. |
Minimum | MIN(number1, number2, ...) | Returns the smallest number in the input list, ignoring nonnumerical items. |
MINA | MINA(value1, value2, ...) | Returns the smallest number in the input list, treating boolean TRUE as 1 and any other nonnumerical items as 0. |
Minus | -number | Inverts the sign of the input number. |
Mode | MODE(number1, number2, ...) | Returns the most common item in the input list. |
Modulo | number1 # number2 | Returns the remainder of number1 divided by number2. |
Multiplication | number1 * number2 | Multiplies two numbers. |
Odd | ODD(number) | Returns the closest odd number to the input number. |
Pi | PI() | Mathematical constant: The ratio of a circle's circumference to its diameter. |
Power | x ^ y | Returns x raised to the yth power. |
Product | PRODUCT(number1, number2, ...) | Returns the product of numbers in the list. |
Quotient | QUOTIENT(number1, number2) | Divides two numbers, dropping the fractional part. |
Round |
ROUND(x) ROUND(x; n) |
If only one argument is provided, rounds x to the nearest integer. If both x and n are provided, rounds x to n decimal places. |
Round Down |
ROUNDDOWN(x) ROUNDDOWN(x; n) |
Rounds x down to the nearest integer if only one argument is provided. If both x and n are specified, rounds x down to the specified number of decimal places. |
Round Mult | MROUND(number, multiple) | Rounds number to the nearest multiple of multiple. If there are two nearest multiples, MROUND rounds up. |
Round Up |
ROUNDUP(x) ROUNDUP(x; n) |
Rounds x up to the nearest integer if only one argument is provided. If both x and n are specified, rounds x up to the specified number of decimal places. |
Sign | SIGN(number) | Returns a number indicating the sign of the input number. For negative inputs, it returns -1; for zero-value inputs, 0; for positive inputs, 1. |
Square Root | SQRT(number) | Returns the square root of the input number. |
Subtraction | number1 - number2 | Subtracts number2 from number1. |
Sum If | SUMIF([number1, number2, ...], condition) | Sums the items that satisfy the provided condition. |
Summation | SUM(number1, number2, ...) | Sums a list, ignoring nonnumerical items. |
Truncate | TRUNC(number, n) |
Truncates number to have only n decimal places. Unlike ROUNDDOWN and ROUNDUP, no rounding is carried out. For example, TRUNC(123.456, 2) returns 123.4. If n is negative, truncation occurs to the left of the decimal point. For example, TRUNC(123, -1) returns 120. |
Boolean
Name | Format | Description |
---|---|---|
And | boolean1 && boolean2 | Boolean "AND" operation on the input list. Use AND( , ) syntax for lists or multi-value tokens. |
Equal | value1 = value2 | Returns TRUE if value1 and value2 are equal, otherwise returns FALSE. |
Greater Than | value1 > value2 | Returns TRUE if value1 is greater than value2, otherwise returns FALSE. |
Greater Than Or Equal | value1 >= value2 | Returns TRUE if value1 is greater than or equal to value2, otherwise returns FALSE. |
If | IF(condition, true_case, false_case) | If condition is true, returns true_case. Otherwise, false_case is returned. |
Is Email | ISEMAIL(value) | Checks if the input item is a valid email string. |
Is Even | ISEVEN(number) | Checks if the input item is an even number. |
Is Not Text | ISNONTEXT(value) | Checks if the input item is not a string. |
Is Number | ISNUMBER(value) | Checks if the input item is a number. |
Is Odd | ISODD(number) | Checks if the input item is an odd number. |
Less Than | value1 < value2 | Returns TRUE if value1 is less than value2, otherwise returns FALSE. |
Less Than Or Equal | value1 <= value2 | Returns TRUE if value1 is less than or equal to value2, otherwise returns FALSE. |
Not | !value1 | Logical NOT; treats 0 as FALSE, other values as TRUE. |
Not Equal | value1 <> value2 | Returns TRUE if value1 and value2 are not equal, otherwise returns FALSE. |
Or | boolean1 || boolean2 | Boolean "OR" operation on the input list. Use [OR( , )] syntax for lists or multi-value tokens. |
Date
Note: The correct syntax for a date argument is "Date(year, month, day)." For example, if you want to enter April 15, 2017 in the workday formula, do not write "WORKDAY(4/15/2017, 4)." Instead, write "WORKDAY(DATE(2017, 4, 15), 4)" or, if you are using a date token, "WORKDAY(%(date), 4)."
Name | Format | Description |
---|---|---|
Add Month | ADD_MONTHS(date, number) | Returns the date that is number months after date. Supports fractional month numbers. |
Date | Date(year, month, day) | Constructs a date value from the arguments. |
Date Diff | DATEDIF(date1, date2, string) | Returns the difference between date1 and date2. string specifies the unit: "Y"/"y" for years, "M"/"m" for months, "D"/"d" for days. |
Date Value | DATEVALUE(string) | Constructs a date from the input string. |
Day | DAY(date) | Returns the day of the input date. |
Days 360 | DAYS360(date1, date2) | Returns the number of days between date1 and date2, assuming that a year is 360 days. |
Epoch | EPOCH(n) | Returns the datetime that is n seconds after the Unix epoch time. |
Hour | HOUR(date) | Returns the hour of the input datetime. |
Minute | MINUTE(date) | Returns the minute of the input datetime. |
Month | MONTH(date) | Returns the month of the input datetime. |
Now | NOW() | Returns the current date and time. |
Round Date | EDATE(date, number) | Returns a date that is date plus number months. |
Round Month | EOMONTH(date, number) | Adds number months to date, then rounds the result to the last day of the month. |
Second | SECOND(datetime) | Returns the second of the input datetime. |
Time | TIME(hours, minutes, seconds) | Returns the input time as a fraction of the day. |
Time Value | TIMEVALUE(string) | Returns the input time as a fraction of the day. Inputs can be in the form HH:MM, HH:MM:SS, or YYYY-MM-DD HH:MM:SS. |
Today | TODAY() | Returns the current date. |
Week Number | WEEKNUM(date) | Returns the week of the year that the input date falls in. |
Work Date | WORKDAY(date, number) | Returns a date that is date plus number work days. |
Work Days | NETWORKDAYS(date1, date2) | Returns the number of work days between date1 and date2. |
Year | YEAR(date) | Returns the year of date. |
Year Fraction |
YEARFRAC(date1, date2) YEARFRAC(date1, date2, basis) |
Calculates the difference between date1 and date2 in years, including fractions of years. Returns a positive value regardless of whether date1 or date2 is the later date. If date1 and date2 are the only arguments provided, the calculation assumes the US (NASD) 30/360 day count convention. Otherwise, year fractions are calculated depending on the value of basis as follows:
|
String
Name | Format | Description |
---|---|---|
Char To Code | CODE(char) | Returns the ASCII code of the input character. |
Code To Char | CHAR(number) | Converts the input ASCII code to a string. |
Concatenate | string1 & string2 | Concatenates the input strings. |
Dollar | DOLLAR(number) |
Returns the input number as a string representing a dollar amount.
|
Exact | EXACT(value1, value2) | Determines whether the two inputs are identical strings. |
Find | FIND(key, string) | Searches for key in the input string in a case-sensitive manner. Returns the first matched position or -1 if not found. |
Fixed | FIXED(number) | Rounds the number to a specified number of decimal places and formats the result as text. |
Join | JOIN(string_separator, [string1, string2, ...]) | Joins the items of the string array with string_separator between them. |
Left | LEFT(string, n) | Returns the n leftmost characters in the input string. |
Lower | LOWER(string) | Returns a lowercase version of the string. |
Mid | MID(string, n, length) | Returns length characters from string, starting at the nth character. |
Number Value |
NUMBERVALUE(string) NUMBERVALUE(string, decimal_separator, group_separator) |
Parses the input string as a number. You can specify optional decimal point and group separators. If no separators are specified, Workflow assumes that you use periods for decimal points and commas to separate thousands. Percentages are also converted. For example, NUMBERVALUE("35%") returns 0.35. |
Proper Text | PROPER(string) | Returns the input string with the first letter of each word converted to uppercase and the remaining letters converted to lowercase. |
Repeat | REPT(string, number) | Returns the string repeated number times. |
Replace | REPLACE(input_string, n, length, new_string) | Replaces part of input_string, starting from its nth character and going for length characters, with new_string. |
Right | RIGHT(string, n) | Returns the n rightmost characters in the input string. |
Roman | ROMAN(number) | Returns a Roman numeral string representing the input number. |
Search | SEARCH(key, string) | Searches for key in the input string, returning the first matched position or -1 if not found. |
Split | SPLIT(string, delimiter) | Splits the input string at each instance of the delimiter into an array. |
String Length | LEN(string) | Returns the length of the input string. |
Substitute | SUBSTITUTE(input_string, old_string, new_string) |
Substitutes new_string for old_string in the input string. |
Text | TEXT(value) | Returns a string version of the input value. |
Trim | TRIM(string) | Removes leading and trailing spaces, and replaces all internal multiple spaces with a single space in the input string. |
Upper | UPPER(string) | Returns an uppercase version of string. |
Value | VALUE(string) | Converts the input string into a number. |
Substituting Double Quotes
Because double quotes are special characters, using them in string functions necessitates some workarounds. As a rule of thumb, you can use CHAR(34) instead of a double quote when you want to carry out a string operation on a double quote. For example, to remove all double quotes from a string, you can enter SUBSTITUTE(input_string, CHAR(34), ""). This replaces all double quotes in input_string with the empty string, effectively removing them.